package com.cuit.pojo;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Document(indexName = "books", type = "logs")
@TableName(value = "book as b LEFT JOIN user as u on b.userId=u.id")
public class BookUser {
    @TableId(value = "b.id")
    @Id
    private Integer id;

    @TableField(value = "b.userId")
    @Field(type=FieldType.Long)
    private  Integer userId;

    @TableField(value = "b.bookName")
    @Field(type= FieldType.Text)
    private  String bookName;

    @Field(type= FieldType.Text)
    @TableField(value = "b.bookImg")
    private  String bookImg;

    @Field(type= FieldType.Text)
    @TableField(value = "b.bookTypeName")
    private String bookType;

    @TableField(value = "b.bookPrice")
    @Field(type=FieldType.Float)
    private Double bookPrice;

    @Field(type= FieldType.Text)
    @TableField(value = "b.bookDesc")
    private String bookDesc;

    @Field(type= FieldType.Text)
    @TableField(value = "u.avatar")
    private  String userImg;

    @Field(type= FieldType.Text)
    @TableField(value = "u.username")
    private  String userName;

    @TableField(value = "b.sellnum")
    @Field(type=FieldType.Long)
    private Long sellnum;
}
